<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	template="/resources/scaffold/pageTemplate.xhtml">

	<f:metadata>
		<f:viewParam name="id" value="#{animalBean.id}" />
		<f:event type="preRenderView" listener="#{animalBean.retrieve}" />
	</f:metadata>

	<ui:param name="pageTitle" value="Create Animal" />

	<ui:define name="header">
		Animal
	</ui:define>

	<ui:define name="subheader">
		<c:choose>
			<c:when test="#{!empty animalBean.id}">
				Edit existing Animal
			</c:when>
			<c:otherwise>
				Create a new Animal
			</c:otherwise>
		</c:choose>
	</ui:define>

	<ui:define name="footer" />

	<ui:define name="main">
		<c:choose>
			<c:when test="#{login.loggedIn}">
				<h:form id="create">
					<h:messages globalOnly="true" styleClass="error" />

					<h:panelGrid columnClasses="label,component,required" columns="3">
						<h:outputLabel for="animalBeanAnimalAnimalType"
							value="Animal Type:" />
						<h:panelGroup>
							<h:selectOneMenu id="animalBeanAnimalAnimalType"
								value="#{animalBean.animal.animalType}">
								<f:selectItem />
								<f:selectItem itemValue="DOG" />
								<f:selectItem itemValue="CAT" />
								<f:selectItem itemValue="SNAKE" />
								<f:selectItem itemValue="MONKEY" />
							</h:selectOneMenu>
							<h:message for="animalBeanAnimalAnimalType" styleClass="error" />
						</h:panelGroup>
						<h:outputText />
						<h:outputLabel for="animalBeanAnimalSize" value="Size:" />
						<h:panelGroup>
							<h:inputText id="animalBeanAnimalSize"
								value="#{animalBean.animal.size}" />
							<h:message for="animalBeanAnimalSize" styleClass="error" />
						</h:panelGroup>
						<h:outputText />
						<h:outputLabel for="animalBeanAnimalFood" value="Food:" />
						<h:panelGroup>
							<h:inputText id="animalBeanAnimalFood"
								value="#{animalBean.animal.food}" />
							<h:message for="animalBeanAnimalFood" styleClass="error" />
						</h:panelGroup>
						<h:outputText />
						<h:outputLabel for="animalBeanAnimalOptionalInfo"
							value="Optional Info:" />
						<h:panelGroup>
							<h:inputText id="animalBeanAnimalOptionalInfo"
								value="#{animalBean.animal.optionalInfo}" />
							<h:message for="animalBeanAnimalOptionalInfo" styleClass="error" />
						</h:panelGroup>
						<h:outputText />
					</h:panelGrid>

					<div class="buttons">
						<h:commandLink value="Save" action="#{animalBean.update}"
							styleClass="btn btn-primary" />
						<c:choose>
							<c:when test="#{!empty animalBean.id}">
								<h:link value="Cancel" outcome="view"
									styleClass="btn btn-primary">
									<f:param name="id" value="#{animalBean.id}" />
								</h:link>
								<h:commandLink value="Delete" action="#{animalBean.delete}"
									styleClass="btn btn-primary" />
							</c:when>
							<c:otherwise>
								<h:link value="Cancel" outcome="search"
									styleClass="btn btn-primary" />
							</c:otherwise>
						</c:choose>
					</div>
				</h:form>

			</c:when>
			<c:otherwise>
				You have no access.
			</c:otherwise>
		</c:choose>
	</ui:define>

</ui:composition>